package com.lynn.accesstoken.service.impl;

import com.lynn.accesstoken.bean.User;
import com.lynn.accesstoken.redis.RedisManager;
import com.lynn.accesstoken.repo.AppEntityRepo;
import com.lynn.accesstoken.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author ly
 * @Date 2019-05-30 15:20
 * @Version 1.0
 */
@Slf4j
@Service
public class UserServiceImpl implements IUserService {

    private RedisManager redisManager;

    private AppEntityRepo appEntityRepo;

    public UserServiceImpl(RedisManager redisManager, AppEntityRepo appEntityRepo) {
        this.redisManager = redisManager;
        this.appEntityRepo = appEntityRepo;
    }

    @Cacheable(value = "load")
    @Override
    public User load() {
        System.out.println(".......");
        User u = User.builder()
                .id(System.currentTimeMillis() + "")
                .name("hello" + System.currentTimeMillis())
                .build();
        System.out.println(u.toString());
        return u;
    }

    /**
     * 通过token获取用户信息
     * @param token
     * @return
     */
    @Override
    public User findOne(String token) {
        log.info("模拟....user");
        User u = User.builder()
                .id(System.currentTimeMillis() + "")
                .name("hello" + System.currentTimeMillis())
                .build();
        return u;
    }
}
